#include <iostream>
#include <string>
using namespace std;

const int N = 1e6 + 5;
typedef unsigned long long LL;

LL st[N],n;

void push(LL x){
	st[++n] = x;
}

void pop(){
	if(n){
		n--;
	}
	else {
		cout << "Empty" << endl;
	}
}

void query(){
	if(n){
		cout << st[n] << endl;
	}
	else{
		cout << "Anguei!" << endl;
	}
}

void size(){
	cout << n << endl;
}

int main(){
	int T;
	cin >> T;
	while(T--){
		n = 0;
		int m;
		cin >> m;
		string str;
		while(m--){
			cin >> str;
			if(str == "push"){
				LL x;
				cin >> x;
				push(x);
			}
			else if(str == "pop"){
				pop();
			}
			else if(str == "query"){
				query();
			}
			else if(str == "size"){
				size();
			}
		}
	}
	return 0;
} 
